// 对象格式的json数据
const sJson = '{"name": "Amy", "age": 26}';
// json字符串转换成JavaScript对象
let oPerson = JSON.parse(sJson);
console.log(oPerson);
console.log(oPerson.name);
// 生成json字符串
console.log(JSON.stringify(oPerson, null, 4));

// 数组格式的json数据
const aArray = '[{"name": "Amy", "age": 26}, {"name": "Jerry", "age": 32}]';
// json字符串转换成Array数组
let arr = JSON.parse(aArray);
console.log(arr);
// 生成json字符串
console.log(JSON.stringify(arr, null, 4))
// for(var i = 0; i < aArray.length; i++){
//     console.log(aArray[i]);
// }
arr.forEach(function (v, i) {
    console.log(v, i);
});

arr.forEach((v, i) => {
    console.log(v, i);
})

for (let i in arr){
    console.log(i, arr[i]);
}

for (let v of arr){
    console.log(v);
}